home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-06-15 | 13.6 KB | 405 lines | [TEXT/MPS ] |
- #######################################################################################
- # InitMemoryMonitor( OnTarget := false )
- #
- # Prepares Memory Monitor as an external tool.
- #
- # Input:
- #
- # OnTarget
- # Pass in true if Memory Monitor is to run on a target, false for the Host.
- # By default Memory Monitor runs on the Host
- #
- #######################################################################################
- Task InitMemoryMonitor( OnTarget := false )
- Begin
- x := MemoryMonitor( "Initialize", OnTarget );
- Script_Error := ScriptError();
- return { x[1], x[2], x[3], Script_Error };
- end;
-
-
- #######################################################################################
- # QuitMemoryMonitor()
- #
- # Causes Memory Monitor application to 'Quit'.
- #
- #######################################################################################
- Task QuitMemoryMonitor()
- Begin
- x := MemoryMonitor( "Quit" );
- Script_Error := ScriptError();
- return { x[1], x[2], x[3], Script_Error };
- end;
-
-
- #######################################################################################
- # GetAllProcesses( pCallAsync := false )
- #
- # Returns a list of all processes which are currently running.
- #
- # Input:
- #
- # pCallAsync boolean Determines wheather the tool is called asynchronously
- #
- # Output:
- #
- # The return value is a list of ProcessRecord elements: { ProcRec, ProcRec, ... }
- # Each ProcessRecord element is a list containing the following elements
- #
- # Index Data Type Label Significance
- # ----- --------- ----- ------------
- # 1 string Name The name of the process
- # 2 string Type The 4 letter type code
- # 3 string Signature The 4 letter signature code
- # 4 string Location Decimal digits of address of the heap zone
- # 5 string Size Decimal digits of heap zone size in bytes
- # 6 string Free Decimal digits of Free Memory in bytes
- # 7 string Pathname Pathname to the file from which the process came
- #
- #######################################################################################
- Task GetAllProcesses( pCallAsync := false )
- Begin
- x := MemoryMonitor( "GetAllProcesses" ) Async:pCallAsync;
- Script_Error := ScriptError();
- return { x[1], x[2], x[3], Script_Error };
- end;
-
-
- #######################################################################################
- # GetProcessInfo( ProcName, pCallAsync := false )
- #
- # Returns Process Manager information for the process specified
- # by the ProcName paramter
- #
- # Input:
- #
- # ProcName string The name of the process of interest
- # pCallAsync boolean Determines wheather the tool is called asynchronously
- #
- # Output:
- #
- # return value is a ProcessRecord containing the following elements
- #
- # Index Data Type Label Significance
- # ----- --------- ----- ------------
- # 1 string Name The name of the process
- # 2 string Type The 4 letter type code
- # 3 string Signature The 4 letter signature code
- # 4 string Location Decimal digits of address of the heap zone
- # 5 string Size Decimal digits of heap zone size in bytes
- # 6 string Free Decimal digits of Free Memory in bytes
- # 7 string Pathname Pathname to the file from which the process came
- #
- #######################################################################################
- Task GetProcessInfo( ProcName, pCallAsync := false )
- Begin
- x := MemoryMonitor( "GetProcessInfo", ProcName ) Async:pCallAsync;
- Script_Error := ScriptError();
- return { x[1], x[2], x[3], Script_Error };
- end;
-
-
- #######################################################################################
- # GetZoneMap( ZoneSelector, pCallAsync := false )
- #
- # Returns a list containing location and size info for the specified zone
- # and all zones nested within the specified zone.
- #
- # Input:
- #
- # ZoneSelector Determines which heap zone, may be of two forms:
- #
- # Form 1: string
- # The process/zone name
- #
- # Example 'Finder' - the Finder's heap zone
- #
- # Form 2: { string [[,integer] ...] }
- # Element 1 determines the root heap zone
- # Each following index specifies which nested heap zone
- #
- # Example { 'Virtual User', 1 } - first nested heap zone within Virtual User
- #
- # There are two names which can be used in the place of a prcess name
- # 'SystemZone' and 'MultiFinderZone'. These values allow access
- # to the two root heap zones.
- #
- # Example { 'System', 1 } - The first nested heap within the System heap.
- #
- # pCallAsync boolean Determines wheather the tool is called asynchronously
- #
- # Output:
- #
- # The return value is a list of ZoneRecord elements: { ZoneLoc, ZoneLoc, ... }
- # Note the fourth element is a list which may contain more ZoneRecord elements.
- # Since heap zones can be nested, ZoneRecords can also be nested.
- #
- # Index Data Type Label Significance
- # ----- --------- ----- ------------
- # 1 string StartAddress Decimal digits of address where heap zone begins
- # 2 string EndAddress Decimal digits of address where heap zone ends
- # 3 string Size Decimal digits of size of the heap zone in bytes
- # 4 list NestedZones List of all nested heap zones
- #
- #######################################################################################
- Task GetZoneMap( ZoneSelector := "", pCallAsync := false )
- Begin
- x := MemoryMonitor( "GetZoneMap", ZoneSelector ) Async:pCallAsync;
- Script_Error := ScriptError();
- return { x[1], x[2], x[3], Script_Error };
- end;
-
-
- #######################################################################################
- # GetZoneTotals( ZoneSelector, pCallAsync := false )
- #
- # Returns a summary of how memory is allocated within a specified heap zone.
- # The total bytes and number of blocks is returned for each of the following
- # catagories :
- # Free,
- # Relocatable,
- # Non-Relocatable,
- # Non-Relocatable/Locked,
- # Non-Relocatable/Not Locked & Purgable
- #
- # This is similar to Macsbug's HT (heap totals) command
- #
- # Input:
- #
- # ZoneSelector Determines which heap zone, may be of two forms:
- #
- # Form 1: string
- # The process/zone name
- #
- # Example 'Finder' - the Finder's heap zone
- #
- # Form 2: { string [[,integer] ...] }
- # Element 1 determines the root heap zone
- # Each following index specifies which nested heap zone
- #
- # Example { 'Virtual User', 1 } - first nested heap zone within Virtual User
- #
- # There are two names which can be used in the place of a prcess name
- # 'SystemZone' and 'MultiFinderZone'. These values allow access
- # to the two root heap zones.
- #
- # Example { 'System', 1 } - The first nested heap within the System heap.
- #
- # pCallAsync boolean Determines wheather the tool is called asynchronously
- #
- # Output:
- #
- # return value is a list of one element for each catagory of block allocation type
- # Each element is itself a list containing two values, number of blocks and total bytes
- # 'number of blocks' is an integer value, and 'total bytes' is a string of decimal digits
- #
- # Index Data Type Label Significance
- # ----- --------- ----- ------------
- # 1 list Free { number of blocks, total bytes }
- # 2 list Relocatable { number of blocks, total bytes }
- # 3 list Non-Relocatable { number of blocks, total bytes }
- # 4 list Non-Relocatable/Locked { number of blocks, total bytes }
- # 5 list Non-Relocatable/Not Locked & Purgable { number of blocks, total bytes }
- # 6 list Total { number of blocks, total bytes }
- #
- #######################################################################################
- Task GetZoneTotals( ZoneSelector, pCallAsync := false )
- Begin
- x := MemoryMonitor( "GetZoneTotals", ZoneSelector ) Async:pCallAsync;
- Script_Error := ScriptError();
- return { x[1], x[2], x[3], Script_Error };
- end;
-
-
- #######################################################################################
- # CheckZone( ZoneSelector, pCallAsync := false )
- #
- # Checks the Memory Manager data structures within the specified heap zone
- # Returns true if no inconsistencies are found.
- #
- # This is similar to Macsbug's HC (heap check) command
- #
- # Input:
- #
- # ZoneSelector Determines which heap zone, may be of two forms:
- #
- # Form 1: string
- # The process/zone name
- #
- # Example 'Finder' - the Finder's heap zone
- #
- # Form 2: { string [[,integer] ...] }
- # Element 1 determines the root heap zone
- # Each following index specifies which nested heap zone
- #
- # Example { 'Virtual User', 1 } - first nested heap zone within Virtual User
- #
- # There are two names which can be used in the place of a prcess name
- # 'SystemZone' and 'MultiFinderZone'. These values allow access
- # to the two root heap zones.
- #
- # Example { 'System', 1 } - The first nested heap within the System heap.
- #
- # pCallAsync boolean Determines wheather the tool is called asynchronously
- #
- # Output:
- #
- # The return value is a symbol : either true or false
- #
- #######################################################################################
- Task CheckZone( ZoneSelector, pCallAsync := false )
- Begin
- x := MemoryMonitor( "CheckZone", ZoneSelector ) Async:pCallAsync;
- Script_Error := ScriptError();
- return { x[1], x[2], x[3], Script_Error };
- end;
-
-
-
- #######################################################################################
- # GetAboutThisMacintosh( pCallAsync := false )
- #
- # Returns information contained in the "About this Macintosh" box.
- #
- # Input:
- #
- # pCallAsync boolean Determines wheather the tool is called asynchronously
- #
- # Output:
- #
- # The return value is a list of items from Finder's About Box ( "About This Macintosh" ).
- # Each element of the list is as follows:
- #
- # Index Data Type Label Significance
- # ----- --------- ----- ------------
- # 1 string PhysicalRAM Decimal digits of 'Built-in Memory'
- # 2 string LogicalRAM Decimal digits of 'Total Memory'
- # 3 string LargestBlock Decimal digits of 'Largest unused block'
- # 4 list Processes List of info for each process
- #
- # The 'Processes' element is a list containing one of the following records
- # for each process.
- #
- # Index Data Type Label Significance
- # ----- --------- ----- ------------
- # 1 string Name Process name
- # 2 string LargestBlock Decimal digits of process size in bytes
- #
- #######################################################################################
- Task GetAboutThisMacintosh( pCallAsync := false )
- Begin
- x := MemoryMonitor( "GetAboutThisMacintosh" ) Async:pCallAsync;
- Script_Error := ScriptError();
- return { x[1], x[2], x[3], Script_Error };
- end;
-
- #######################################################################################
- # ReadBytes( pAddress, pCount, pCallAsync := false )
- #
- # Returns a list of contiguous bytes from memory
- #
- # Input:
- #
- # pAddress list The location of the first byte to read.
- # The list must contain the High & Low words of the address
- #
- # pCount integer The number of bytes to read
- #
- # pCallAsync boolean Determines wheather the tool is called asynchronously
- #
- # Output:
- #
- # The return value is a list of integers.
- # Each one is equal to the value of the byte read from memory.
- #
- #######################################################################################
- Task ReadBytes( pAddress, pCount, pCallAsync := false )
- Begin
- x := MemoryMonitor( "ReadBytes", pAddress, pCount ) Async:pCallAsync;
- Script_Error := ScriptError();
- return { x[1], x[2], x[3], Script_Error };
- end;
-
- #######################################################################################
- # MacsbugCmd( Commands, Label := "Memory Moniotr", RemainInMacsBug := false, pCallAsync := false )
- #
- # Executes a Macsbug command, via Macsbug command line
- #
- # Input:
- #
- # Commands string One or more Macsbug commands, separated by semi-colons.
- #
- # Label string Optional label which is desplayed in Macsbug,
- # prior to command line execution
- #
- # RemainInMacsBug string if false, a "Go" command is appended to the command line
- # otherwise, no "Go" command is appeded. This makes it possible
- # to remain in Macsbug ( for what ever reason )
- #
- # pCallAsync boolean Determines wheather the tool is called asynchronously
- #
- # Output:
- #
- # The return value is the 'true' symbol if successful, otherwise 'undefined'
- #
- #######################################################################################
- Task MacsbugCmd( CommandLine, Label := "Memory Monitor", RemainInMacsBug := false, pCallAsync := false )
- Begin
- ### Append a "Go" command so we won't stay in Macsbug
- if RemainInMacsBug
- begin
- CommandLine := "{Label}; {CommandLine}";
- end;
- else
- begin
- CommandLine := "{Label}; {CommandLine} ;g";
- end;
-
- x := MemoryMonitor( "MacsbugCmd", CommandLine ) Async:pCallAsync;
- Script_Error := ScriptError();
- return { x[1], x[2], x[3], Script_Error };
- end;
-
-
- #######################################################################################
- # MemoryMonitor Tool Declaration
- #
- # Defines the V.U. scripting interface to Memory Monitor
- #
- Tool MemoryMonitor s:'MMTL'
- begin
- #####################################################
- ### Services specific to Memory Monitor:
-
- ### Process Manager
- Service "GetAllProcesses"( ) return 'list';
- Service "GetProcessInfo"( ) return 'list';
-
- ### Heap Zone
- Service "GetZoneMap"( 'undefined' ) return 'list';
- Service "GetZoneTotals"( 'undefined' ) return 'list';
- Service "CheckZone"( 'undefined' ) return 'symbol';
-
- ### Finder's About Box
- Service "GetAboutThisMacintosh"( ) return 'list';
-
- ### Reading Memory
- Service "ReadBytes"( 'list', 'integer' ) return 'list';
-
- ### Macsbug Command
- Service "MacsbugCmd"( 'string' ) return 'symbol';
-
- #####################################################
- ### Services common to all Virtual User external tools:
-
- Service "Initialize" ( 'undefined' );
- Service "Cancel" ( 'string' );
- Service "Poll" ( 'string' ) return 'string';
- Service "ServiceSupported" ( 'string' ) return 'undefined';
- Service "GetToolServices" () return 'list';
- Service "GetToolVersion" () return 'list';
- Service "Quit"();
-
- end;
-
-